/**
 * 
 */
package jgame.StoryTeller;

import java.util.ArrayList;

/**
 * @author Justin
 *
 */
public class JGameStorySet {
	
	private int EXT_ID;
	private String TITLE;
	private ArrayList<JGameStoryScene> SCENES;
	private ArrayList<String> STUFF;
	
	public JGameStorySet(int ext_id, String title, ArrayList<String> scenes_and_stuff)
	{
		SCENES = new ArrayList<JGameStoryScene>();
		STUFF = new ArrayList<String>();
		String sceneID = "", sceneText = "";
		
		
		EXT_ID = ext_id;
		TITLE = title;
		
		for(int i = 0; i<scenes_and_stuff.size(); i++)
		{
			if(scenes_and_stuff.get(i).substring(0,1).equals("#"))
			{				
				if(i>0)
				{
					
					SCENES.add(new JGameStoryScene(Integer.parseInt(sceneID), sceneText, STUFF));
				}
				
				STUFF.clear();
				
				sceneID = scenes_and_stuff.get(i).substring(1,7);	sceneText = scenes_and_stuff.get(i).substring(8,scenes_and_stuff.get(i).length());
			}
			
			else
				STUFF.add(scenes_and_stuff.get(i));
			
			if(i==scenes_and_stuff.size()-1)
				SCENES.add(new JGameStoryScene(Integer.parseInt(sceneID), sceneText, STUFF));
		}
	}
	
	public int getExtID()
	{
		return EXT_ID;
	}
	
	public String getTitle()
	{
		return TITLE;
	}
	
	public void test()
	{
		System.out.println(EXT_ID + ": " + TITLE);
		
		for(int i = 0; i<SCENES.size(); i++)
		{
			SCENES.get(i).test();
		}
	}

	public JGameStoryScene getScene(int state) 
	{
		for(int i = 0; i<SCENES.size(); i++)
		{
			if(SCENES.get(i).getIntID()==state)
				return SCENES.get(i);
		}
		
		return null;
	}
}
